package com.ljf.daily.costmanagement.web;

import com.ljf.common.exception.ServiceException;
import com.ljf.common.result.ResultModel;
import com.ljf.common.validation.AddGroup;
import com.ljf.common.validation.QueryGroup;
import com.ljf.common.validation.UpdateGroup;
import com.ljf.common.web.BasisController;
import com.ljf.daily.costmanagement.dto.command.DailyDatCostManagementCommand;
import com.ljf.daily.costmanagement.dto.command.DailyDatCostManagementConfigCommand;
import com.ljf.daily.costmanagement.dto.command.DailyDatCostManagementDetailCommand;
import com.ljf.daily.costmanagement.dto.query.DailyDatCostManagementDetailOperateQuery;
import com.ljf.daily.costmanagement.dto.query.DailyDatCostManagementDetailQuery;
import com.ljf.daily.costmanagement.dto.query.DailyDatCostManagementQuery;
import com.ljf.daily.costmanagement.service.IDailyDatCostManagementService;
import com.ljf.daily.costmanagement.vo.DailyDatCostManagementVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 费用管理  控制器
 *
 * @author LJF
 * @since 2025-03-30
 */
@RestController
@RequestMapping("/daily/dat/cost_management")
@Api(value = "费用管理接口", tags = "费用管理接口")
public class DailyDatCostManagementController extends BasisController<IDailyDatCostManagementService, DailyDatCostManagementQuery, DailyDatCostManagementVO, DailyDatCostManagementCommand> {

    // 基本API
    @GetMapping("/activity/list")
    @ApiOperation(value = "查询活动费用管理接口")
    public ResultModel queryActivityList() throws ServiceException {
        return service.queryActivityList();
    }

    // 配置API
    @PutMapping("/config")
    @ApiOperation(value = "更新待摊费用配置接口")
    public ResultModel editConfig(@RequestBody @Validated(UpdateGroup.class) DailyDatCostManagementConfigCommand command) throws ServiceException {
        return service.editConfig(command);
    }

    @GetMapping("/config/{id}")
    @ApiOperation(value = "根据ID查询待摊费用配置接口")
    public ResultModel queryConfigById(@PathVariable Long id) throws ServiceException {
        return service.queryConfigById(id);
    }

    // 外部API
    @GetMapping("/symbol")
    @ApiOperation(value = "查询费用管理标签接口")
    public ResultModel querySymbol() throws ServiceException {
        return service.querySymbol();
    }

    // 基本API
    @PostMapping("/detail")
    @ApiOperation(value = "新增费用明细接口")
    public ResultModel addDetail(@RequestBody @Validated(AddGroup.class) DailyDatCostManagementDetailCommand command) throws ServiceException {
        return service.addDetail(command);
    }

    @DeleteMapping("/detail/{id}")
    @ApiOperation(value = "删除费用明细接口")
    public ResultModel deleteDetail(@PathVariable Long id) throws ServiceException {
        return service.deleteDetail(id);
    }

    @PutMapping("/detail")
    @ApiOperation(value = "更新费用明细接口")
    public ResultModel editDetail(@RequestBody @Validated(UpdateGroup.class) DailyDatCostManagementDetailCommand command) throws ServiceException {
        return service.editDetail(command);
    }

    @PutMapping("/detail/consume")
    @ApiOperation(value = "消耗费用明细接口")
    public ResultModel consumeDetail(@RequestBody @Validated(UpdateGroup.class) DailyDatCostManagementDetailCommand command) throws ServiceException {
        return service.consumeDetail(command);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "分页查询费用明细接口")
    public ResultModel queryDetail(@Validated(QueryGroup.class) DailyDatCostManagementDetailQuery query) throws ServiceException {
        return service.queryDetail(query);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "根据ID查询费用明细接口")
    public ResultModel queryDetailById(@PathVariable Long id) throws ServiceException {
        return service.queryDetailById(id);
    }

    // 基本API
    @GetMapping("/detail_operate")
    @ApiOperation(value = "分页查询费用明细操作接口")
    public ResultModel queryDetailOperate(@Validated(QueryGroup.class) DailyDatCostManagementDetailOperateQuery query) throws ServiceException {
        return service.queryDetailOperate(query);
    }

}